/**
 * mcp客户端接口
 */
const mcpClientApi = {
    /**
     * 全部MCP
     *
     * @param {string} [bot] 智能体编号
     * @returns {Promise<McpWholeResponse[]>}
     * @author zero
     */
    whole(bot?: string): Promise<McpWholeResponse[]> {
        return $request.get<McpWholeResponse[]>({
            url: '/agent/mcp/client/whole',
            params: {
                bot
            }
        })
    },

    /**
     * MCP工具
     *
     * @param {string} url MCP地址
     * @returns {Promise<McpToolsResponse[]>}
     * @author zero
     */
    get_tools(url: string): Promise<McpToolsResponse[]> {
        return $request.post({
            url: '/agent/mcp/client/get_tools',
            params: {
                url
            }
        })
    },

    /**
     * MCP运行
     *
     * @param {Object} params
     * @param {string} params.url MCP地址
     * @param {string} params.tool_name 工具名称
     * @param {Record<string, any>} params.tool_args 参数
     * @returns {Promise<any>}
     * @author zero
     */
    call_tool(params: {
        url: string;
        tool_name: string;
        tool_args?: Record<string, any>
    }): Promise<any> {
        return $request.post({
            url: '/agent/mcp/client/call_tool',
            params
        })
    },

    /**
     * MCP列表
     *
     * @param {Object} params
     * @param {number} [params.page_no] 当前页码
     * @param {number} [params.page_size] 每页条数
     * @param {string} [params.keyword] 搜索关键词
     * @returns {Promise<McpListResponse[]>}
     * @author zero
     */
    lists(params: {
        page_no?: number;
        page_size?: number;
        keyword?: string;
    }): Promise<McpListResponse[]> {
        return $request.get<McpListResponse[]>({
            url: '/agent/mcp/client/lists',
            params
        })
    },

    /**
     * MCP列表
     *
     * @param {string} code
     * @returns {Promise<McpDetailResponse>}
     * @author zero
     */
    detail(code: string): Promise<McpDetailResponse> {
        return $request.get<McpDetailResponse>({
            url: '/agent/mcp/client/detail',
            params: {
                code
            }
        })
    },

    /**
     * MCP新增
     *
     * @param {Object} params
     * @param {string} params.name MCP名称
     * @param {string} params.url MCP地址
     * @param {McpToolsResponse[]} [params.tools] MCP工具
     * @returns {Promise<any>}
     * @author zero
     */
    add(params: {
        name: string;
        url: string;
        tools: McpToolsResponse[]
    }): Promise<any> {
        return $request.post({
            url: '/agent/mcp/client/add',
            params
        })
    },

    /**
     * MCP编辑
     *
     * @param {Object} params
     * @param {string} params.code MCP编号
     * @param {string} params.name MCP名称
     * @param {string} params.logo MCP图标
     * @param {string} params.intro MCP简介
     * @returns {Promise<any>}
     * @author zero
     */
    edit(params: {
        code: string;
        name: string;
        logo: string;
        intro: string;
    }): Promise<any> {
        return $request.post({
            url: '/agent/mcp/client/edit',
            params
        })
    },

    /**
     * MCP删除
     *
     * @param {string} code MCP编号
     * @returns {Promise<any>}
     * @author zero
     */
    delete(code: string): Promise<any> {
        return $request.post({
            url: '/agent/mcp/client/delete',
            params: {
                code
            }
        })
    }
}

export default mcpClientApi
